package cc.eddic.practice.spring.dto;

import cc.eddic.practice.spring.domain.Category;
import cc.eddic.practice.spring.domain.SubCategory;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CategoryResponse {
    private Long id;
    private String name;
    private SubCategory subCategory;
    private LocalDateTime createdOn;
    private LocalDateTime updateOn;
    private Integer version;

    public static CategoryResponse from(final Category category) {
        val dto = new CategoryResponse();
        BeanUtils.copyProperties(category, dto);
        return dto;

    }
}
